
<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title>用户登录</title>
		<link rel="stylesheet" href="css/bootstrap.min.css">
		<style>
			.wrap{
				width: 1000px;
				margin:100px auto;
			}
		</style>
	</head>
	<body>
		<div class='wrap'>
			<h2>用户登录</h2>
			<hr>
			<div class="form-group">
				<label for="username">用户名</label>
				<input type="email" class="form-control" id="username" placeholder="请输入用户名">
			</div>
			<div class="form-group">
				<label for="password">密码</label>
				<input type="password" class="form-control" id="password" placeholder="请输入密码">
			</div>

			<div class="checkbox">
				<label>
					<input type="checkbox"> 30天内免登陆
				</label>
			</div>
			<button type="submit" class="btn btn-primary" id="login">登录</button>
			<a href="/register.html">没有帐号，前往注册</a>
		</div>
		<script src="library/jquery.min.js"></script>
		<script>
			$("#login").click(function(){
				if($("#username").val() && $("#password").val()){
					$.ajax({
						url:"http://10.35.170.110/login",
						data:{
							username:$("#username").val(),
							password:$("#password").val(),
						},
						success:function(data){
							if(data === "success"){
								sessionStorage.setItem("username",$("#username").val());
								location.href = "http://10.35.170.110/index.html"
							}else{
								alert("用户名或密码输入错误！")
							}
						}
					})
				}else{
					alert("请输入用户名和密码！")
				}
			})
		</script>
	</body>
</html>
